<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>清除浮动</title>
    <style>
        .outer {
            width: 200px;
            background: tomato;
            margin: 10px;
            position: relative;
        }
        .inner {
            width: 100px;
            height: 100px;
            background: pink;
            margin: 10px;
            float: left;
        }
        .outer1::after {
            content: '';
            display: block;
            clear: both;
        }
        .outer2 {
            overflow: hidden;
        }
    </style>
</head>
<body>
<div class="outer outer1">
    <div class="inner"></div>
</div>
<div class="outer outer2">
    <div class="inner"></div>
</div>
</body>
</html>